package common;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class FileInfo {
    private String fileName; // 文件名
    private List<Integer> blockList; // 该文件对应块序号
    private int status; // 对应StateCode中file状态

    public FileInfo(String fileName) {
        blockList = new LinkedList<>();
        status = StateCode.fileError;
        this.fileName = fileName;
    }

    public FileInfo(String fileName, List<Integer> blockList, int status) {
        this.fileName = fileName;
        this.blockList = blockList;
        this.status = status;
    }

    public void setBlockList(List<Integer> blockList) {
        this.blockList = blockList;
    }

    public int getStatus() {
        return status;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public void appendBlock(int blockIdx) {
        blockList.add(blockIdx);
    }

    public boolean isEmpty() {
        return this.blockList.isEmpty();
    }

    public List<Integer> getBlockList(){
        return Collections.unmodifiableList(blockList);
    }
    public String getFileName() {
        return fileName;
    }
}
